package com.margo.project.web.validator.model;

import java.math.BigDecimal;

import javax.validation.constraints.Digits;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

import com.margo.project.web.validator.customizer.CaseMode;
import com.margo.project.web.validator.customizer.CheckCase;
import com.margo.project.web.validator.customizer.DateTime;

/**
 * 
 * @author fangxingbang
 *
 */
public class MargoValidatorVO {
	
	@NotNull(message="id不能为空")
	private int id;
	
	@NotBlank(message="name不能为空")
	private String name;
	
	@Max(value=150,message="最大年龄不超过150")
	@Min(value=0,message="最小年龄大于0")
	private int age;
	
	@Pattern(regexp = "1[0-9]{10}",message="phone格式不对")
	@NotBlank(message="phone不能为空")
	private String phone;
	
	/**
	 * 时间格式自定义校验 yyyy-MM-dd
	 */
	@DateTime(format="yyyy-MM-dd")
	private String checkDate;
	
	/**
	 * float和double只能用来做科学计算或者是工程计算，在商业计算中我们要用 java.math.BigDecimal。
	 * 而且使用BigDecimal类也可以进行大数的操
	 */
	@Digits(integer=2,fraction=2,message="money小于100 并且只能保留两位小数")
	@Min(value=0,message="money大于0")
	@NotNull(message="money不能为空")
	private BigDecimal money;
	
	/**
	 * 	 double进度丢失
	 */
	@Digits(integer=2,fraction=2,message="score小于100 并且只能保留两位小数")
	@Min(value=0,message="score大于0")
	@NotNull(message="score不能为空")
	private Double score;
	
	/**
	 * 自定义检验规则
	 */
	@CheckCase(value = CaseMode.LOWER,message = "名字的拼音需要小写")
	private String spellName;
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getCheckDate() {
		return checkDate;
	}
	public void setCheckDate(String checkDate) {
		this.checkDate = checkDate;
	}
	public BigDecimal getMoney() {
		return money;
	}
	public void setMoney(BigDecimal money) {
		this.money = money;
	}
	public Double getScore() {
		return score;
	}
	public void setScore(Double score) {
		this.score = score;
	}
	public String getSpellName() {
		return spellName;
	}
	public void setSpellName(String spellName) {
		this.spellName = spellName;
	}
}
